﻿cmake_minimum_required(VERSION 3.10)
# 获取当前子CMake文件所在目录的完整路径 
get_filename_component(CURRENT_DIR_PATH "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) 
# 从完整路径中提取目录名称 
get_filename_component(CURRENT_DIR_NAME "${CURRENT_DIR_PATH}" NAME)

# 设置工程名
project(${CURRENT_DIR_NAME})

set(CMAKE_CXX_STANDARD 11)

# 引入gtest
find_package(GTest CONFIG REQUIRED)

file(GLOB HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h*" "${CMAKE_CURRENT_BINARY_DIR}/src/*.h*")
file(GLOB CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc" )

source_group("Header Files" FILES ${HEADER_FILES})
source_group("Source Files" FILES ${CPP_FILES})

# 创建可执行文件
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${CPP_FILES})

# 添加测试
target_link_libraries(${PROJECT_NAME} 
    GTest::gtest
)
